package com.itheima.vo;

import cn.hutool.core.convert.Convert;
import com.itheima.pojo.UserInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class VoiceVo implements Serializable {
    private Integer id;//用户id
    private String avatar;
    private String nickname;
    private String gender;
    private Integer age;

    private String soundUrl;
    private Integer remainingTimes;//剩余次数

    public static VoiceVo init(UserInfo userInfo, String soundUrl, Integer remainingTimes){
        VoiceVo voiceVo = new VoiceVo();
        voiceVo.setId(Convert.toInt(userInfo.getId()));
        voiceVo.setAvatar(userInfo.getAvatar());
        voiceVo.setNickname(userInfo.getNickname());
        voiceVo.setGender(userInfo.getGender());
        voiceVo.setAge(userInfo.getAge());

        voiceVo.setSoundUrl(soundUrl);
        voiceVo.setRemainingTimes(remainingTimes);

        return voiceVo;
    }
}
